package share

import "oc_saas/model/base"

const (
	Menu      = "M" //菜单
	DIRECTORY = "D" //目录
	PARAM     = "P" //参数
	API       = "A" //接口
)

// 角色规则权限表
type Rule struct {
	base.IDColumn
	base.SortColumn
	PID      uint    `json:"pid"`
	Name     string  `json:"name" gorm:"comment:规则名称;not null;index"`
	Perms    string  `json:"perms" gorm:"comment:权限标识;default:null"`
	Link     string  `json:"-" gorm:"column:link;not null;type:varchar(255);size:255;index;comment:父子元素链条(,a,b,c,)"`
	Children []*Rule `json:"children" gorm:"foreignKey:PID;reference:ID;constraint:OnDelete:CASCADE"`
	Route    *Route  `json:"route,omitempty" gorm:"foreignKey:RuleID;reference:ID;constraint:OnDelete:CASCADE,OnUpdate:CASCADE"`
	Api      *Api    `json:"api,omitempty" gorm:"foreignKey:RuleID;reference:ID;constraint:OnDelete:CASCADE,OnUpdate:CASCADE"`
	// Params   *Params `json:"params,omitempty" gorm:"foreignKey:RuleID;reference:ID;constraint:OnDelete:CASCADE,OnUpdate:CASCADE"`
}
